home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / s_to_z / tpack / inilink.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  25.1 KB  |  804 lines

  1. unit IniLink;
  2.  
  3. {THE POINT: To provide a delphiesque link to INI files using delphi's ini class as a
  4. starting point for a component by wrapping that class into a component.}
  5.  
  6. {FUNCTION: Think of it as an INI file you can visually put on a form. The file can be
  7. opened, closed manually or implicitly when accessed. The filehandele itself is accessible
  8. so you get direct access to TIniFile, plus the support offered by the ..Value Properties}
  9.  
  10. {IT GOES BEYOND THAT: the component is actually three layers.
  11. first we hook up to the file providing a host of features to automate setting the name
  12.   and path as well as providing defaults for the section name.
  13. the second layer adds 'retry' support for reading and writing to the ini file even when
  14.   at first the file is busy. in addition to the standard data types the second layer adds
  15.   support for the Char, Extended, TPoint and TRect types as well as the custom
  16.   TWindowPosValue type that can be used to store/restore control positions and/or
  17.   windowframes using built in procedures. you can access the section/entry item using the
  18.   second level's  ...Value properties.
  19. the third and final layers adds array syntax allowing you to access the supported datatypes
  20.   as arrays in a section. you can access items in a section by name using the third level's
  21.   ...Entry[Entry:String] properties.}
  22.  
  23. {TO USE: do nothing and once you place the component on a form you can access the default
  24. entry in the default section in the default ini file using any ...Value property.
  25. These properties don't show up in the object inspector as every entry in the file could be
  26. of any of the supported types but they are there. see the code below. }
  27.  
  28. interface
  29.  
  30. uses
  31.   SysUtils, Classes, Forms, IniFiles, WinTypes, Controls
  32.   ,Retry
  33.   ,PasUtils
  34.   ,UserInfo
  35.   ,UserWin;
  36.   {define condititional and code flPrivateDirectory}
  37.  
  38. type
  39.   TFileLocation = (flWindowsDir, flNamed, flSystemDir, flExePath); {defaults to flWindowsDir}
  40.   TNameType = (ftNamed, ftExeName, ftWindows, ftSystem, ftControl); {defaults to ftNamed (TEMP.INI)}
  41.  
  42.   TIniFileLinkFile = class(TDialogShell)
  43.     Handle: TIniFile;  {NOTE! Handle to TIniFile is herewith published!}
  44.   private
  45.     fFileName: PString;
  46.     fFilePath: PString;
  47.     fSection: PString;
  48.     fEntry: PString;
  49.  
  50.     fLeaveOpen: Boolean;
  51.     fNameType: TNameType;
  52.     fLocationType: TFileLocation;
  53.     fWindowsUserInfo: TWindowsUserInfo;
  54.   protected
  55.     procedure Notification(AComponent: TComponent; Operation: TOperation); Override;
  56.  
  57.     function GetIniFileName:string;
  58.     procedure SetIniFileName(const Value:String);
  59.     function GetFileName:String;
  60.     procedure SetFileName(const Value:String);
  61.     function GetFilePath:String;
  62.     procedure SetFilePath(const Value:String);
  63.  
  64.     function GetSection:String;
  65.     procedure SetSection(const Value:String);
  66.     function GetEntry:String;
  67.     procedure SetEntry(const Value:String);
  68.  
  69.     procedure SetFileLocation(Value: TFileLocation);
  70.     procedure SetNameType(Value: TNameType);
  71.     function StoreFileName:Boolean;
  72.     function StoreFilePath:Boolean;
  73.  
  74.   public
  75.     constructor Create(AOwner: TComponent); Override;
  76.     destructor Destroy; Override;
  77.     function FileSectionEntry:String;
  78.     function  IsOpen:Boolean;
  79.     procedure Open; {this WILL open the file!}
  80.     procedure Close;
  81.   published
  82.     property FileType: TNameType read fNameType write SetNameType;
  83.     property FileLocation: TFileLocation read fLocationType write SetFileLocation;
  84.     property IniFileName: String read GetIniFileName write SetIniFileName stored false;
  85.     property IniName: String read GetFileName write SetFileName stored StoreFileName;
  86.     property IniPath: String read GetFilePath write SetFilePath stored StoreFilePath;
  87.     property Section: String read GetSection write SetSection;
  88.     property Entry:   String read GetEntry write SetEntry;
  89.     property LeaveOpen: Boolean read fLeaveOpen write fLeaveOpen;      {trigger caching!}
  90.     property WindowsUserInfo: TWindowsUserInfo read fWindowsUserInfo write fWindowsUserInfo;
  91.   end;
  92.  
  93. {-------------------------------------------------------------------------}
  94. {  ADD ADDTL datatypes to the ini inteface                                }
  95. {-------------------------------------------------------------------------}
  96.  
  97.   TWindowPosValue = record
  98.     Top,Left,Height,Width: integer;
  99.     end;
  100.  
  101.   TIniActions = (iaEraseSection,iaEraseEntry
  102.  
  103.                 ,iaGetBool,iaSetBool
  104.                 ,iaGetInt,iaSetInt
  105.                 ,iaGetString,iaSetString
  106.  
  107.                 ,iaGetChar,iaSetChar
  108.                 ,iaGetExt,iaSetExt
  109.                 ,iaGetPoint,iaSetPoint
  110.                 ,iaGetRect,iaSetRect
  111.                 ,iaGetWPos,iaSetWPos
  112.                 );
  113.  
  114.   TIniFileLinkData = class(TIniFileLinkFile)
  115.   protected
  116.     fRetry: TRetry;
  117.     fAction: TIniActions;
  118.  
  119.     fString: PString;
  120.     fBool: Boolean;
  121.     fInteger: Longint;
  122.     fExt: Extended;
  123.     fRect: TRect;
  124.  
  125.   private
  126.     procedure DoAction(Sender:TObject);
  127.     procedure DoIniAction(Action:TIniActions);
  128.  
  129.     function GetBooleanValue:Boolean;
  130.     procedure SetBooleanValue(Value:Boolean);
  131.     function GetLongIntValue:LongInt;
  132.     procedure SetLongIntValue(Value:LongInt);
  133.     function GetStringValue:String;
  134.     procedure SetStringValue(const Value:String);
  135.     function GetCharacterValue:Char;
  136.     procedure SetCharacterValue(Value:Char);
  137.     function GetExtendedValue:Extended;
  138.     procedure SetExtendedValue(Value:Extended);
  139.     function GetPointValue:TPoint;
  140.     procedure SetPointValue(Value:TPoint);
  141.     function GetRectValue:TRect;
  142.     procedure SetRectValue(Value:TRect);
  143.     function GetWindowPosValue:TWindowPosValue;
  144.     procedure SetWindowPosValue(Value:TWindowPosValue);
  145.     function GetOnException:TRetryExceptionEvent;
  146.     procedure SetOnException(Value:TRetryExceptionEvent);
  147.  
  148.   public
  149.     constructor Create(AOwner: TComponent); override;
  150.     destructor Destroy; override;
  151.     procedure EraseSection;    {does what it says}
  152.     procedure EraseEntry;      {so does this}         {properties your code reads/sets}
  153.     procedure StoreControlPos(Control:TControl);
  154.     procedure LoadControlPos(Control:TControl);
  155.     property BooleanValue: Boolean read GetBooleanValue write SetBooleanValue stored false;
  156.     property LongIntValue: LongInt read GetLongIntValue write SetLongIntValue stored false;
  157.     property StringValue: String read GetStringValue write SetStringValue stored false;
  158.     property CharacterValue: char read GetCharacterValue write SetCharacterValue stored false;
  159.     property ExtendedValue: Extended read GetExtendedValue write SetExtendedValue stored false;
  160.     property PointValue: TPoint read GetPointValue write SetPointValue stored false;
  161.     property RectValue: TRect read GetRectValue write SetRectValue stored false;
  162.     property WindowPosValue: TWindowPosValue read GetWindowPosValue write SetWindowPosValue stored false;
  163.   published
  164.     property Retry:      TRetry read fRetry write fRetry;
  165.     property OnException: TRetryExceptionEvent read GetOnException write SetOnException;
  166.   end;
  167.  
  168.  
  169.   TIniFileLink = class(TIniFileLinkData)
  170.   protected
  171.     procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  172.   private
  173.     constructor Create(AOwner: TComponent); override;
  174.       {needs a constructor or virtual methods will not kick in!}
  175.       {try to get this to work without a notification proc at this level! vcl seems
  176.       to be writte with that in mind? can't be!}
  177.  
  178.     function GetBooleanEntry(const aEntry:String):Boolean;
  179.     procedure SetBooleanEntry(const aEntry:String;Value:Boolean);
  180.     function GetLongIntEntry(const aEntry:String):LongInt;
  181.     procedure SetLongIntEntry(const aEntry:String;Value:LongInt);
  182.     function GetStringEntry(const aEntry:String):String;
  183.     procedure SetStringEntry(const aEntry:String;const Value:String);
  184.     function GetCharacterEntry(const aEntry:String):Char;
  185.     procedure SetCharacterEntry(const aEntry:String;Value:Char);
  186.     function GetExtendedEntry(const aEntry:String):Extended;
  187.     procedure SetExtendedEntry(const aEntry:String;Value:Extended);
  188.     function GetPointEntry(const aEntry:String):TPoint;
  189.     procedure SetPointEntry(const aEntry:String;Value:TPoint);
  190.     function GetRectEntry(const aEntry:String):TRect;
  191.     procedure SetRectEntry(const aEntry:String;Value:TRect);
  192.     function GetWindowPosEntry(const aEntry:String):TWindowPosValue;
  193.     procedure SetWindowPosEntry(const aEntry:String;Value:TWindowPosValue);
  194.   public
  195.     property BooleanEntry[const aEntry:String]: Boolean read GetBooleanEntry write SetBooleanEntry;
  196.     property LongIntEntry[const Entry:String]: LongInt read GetLongIntEntry write SetLongIntEntry;
  197.     property StringEntry[const Entry:String]: String read GetStringEntry write SetStringEntry;
  198.     property CharacterEntry[const Entry:String]: char read GetCharacterEntry write SetCharacterEntry;
  199.     property ExtendedEntry[const Entry:String]: Extended read GetExtendedEntry write SetExtendedEntry;
  200.     property PointEntry[const Entry:String]: TPoint read GetPointEntry write SetPointEntry;
  201.     property RectEntry[const Entry:String]: TRect read GetRectEntry write SetRectEntry;
  202.     property WindowPosEntry[const Entry:String]: TWindowPosValue read GetWindowPosEntry write SetWindowPosEntry;
  203.   published
  204.     end;
  205.  
  206. {-------------------------------------------------------------------------}
  207.  
  208. implementation
  209.  
  210. uses wincrt;
  211.  
  212. {-------------------------------------------------------------------------}
  213.  
  214. constructor TIniFileLinkFile.Create(AOwner: TComponent);
  215. begin
  216.   inherited Create(AOwner);
  217.   cx.SetIfFound(fWindowsUserInfo,TWindowsUserInfo);
  218.   fFileName := NullStr;
  219.   fFilePath := NullStr;
  220.   fSection := NullStr;
  221.   fEntry := NullStr;
  222.   Handle := nil;
  223. end;
  224.  
  225. destructor TIniFileLinkFile.Destroy;
  226. begin
  227.   Close;
  228.   DisposeStr(fEntry);
  229.   DisposeStr(fSection);
  230.   DisposeStr(fFilePath);
  231.   DisposeStr(fFileName);
  232.   inherited Destroy;
  233. end;
  234.  
  235. procedure TIniFileLinkFile.Notification(AComponent: TComponent; Operation: TOperation);
  236. begin
  237.   inherited Notification(AComponent, Operation);
  238.   if Operation = opRemove then begin
  239.     cx.NilIfSet(fWindowsUserInfo,AComponent);{say what you mean}
  240.     end;
  241. end;
  242.  
  243. {-------------------------------------------------------------------------}
  244.  
  245. procedure TIniFileLinkFile.SetFileName(const Value: String);
  246. begin
  247.   if Value <> fFileName^ then begin
  248.     Close;
  249.     AssignStr(fFileName,Value);
  250.     end;
  251. end;
  252.  
  253. function TIniFileLinkFile.StoreFileName:Boolean;
  254. begin
  255.   Result:= fNameType=ftNamed;
  256. end;
  257.  
  258. procedure TIniFileLinkFile.SetFilePath(const Value: String);
  259. begin
  260.   if Value <> fFilePath^ then begin
  261.     Close;
  262.     AssignStr(fFilePath,Value);
  263.     end;
  264. end;
  265.  
  266. function TIniFileLinkFile.StoreFilePath:Boolean;
  267. begin
  268.   Result:= fLocationType=flNamed;
  269. end;
  270.  
  271. {-------------------------------------------------------------------------}
  272.  
  273. procedure TIniFileLinkFile.SetFileLocation(Value: TFileLocation);
  274. begin
  275.   if Value <> fLocationType then begin
  276.     case fNameType of
  277.     ftWindows,
  278.     ftSystem,
  279.     ftControl: Value := flWindowsDir;
  280.     ftNamed: AssignStr(fFilePath,'');
  281.       end;
  282.     if Value <> fLocationType then begin
  283.       Close;
  284.       fLocationType := Value;
  285.       end;
  286.     end;
  287. end;
  288.  
  289. procedure TIniFileLinkFile.SetNameType(Value: TNameType);
  290. begin
  291.   if Value <> fNameType then begin
  292.     Close;
  293.     fNameType := Value;
  294.     case Value of
  295.     ftWindows,
  296.     ftSystem,
  297.     ftControl: fLocationType := flWindowsDir;
  298.     ftNamed: AssignStr(fFileName,'');
  299.       end;
  300.     end;
  301. end;
  302.  
  303. {-------------------------------------------------------------------------}
  304.  
  305. function TIniFileLinkFile.GetFileName: String;
  306. begin
  307.   Result:='';
  308.   case fNameType of
  309.   ftNamed: Result:=fFileName^; {as is, might be blank}
  310.   ftExeName: if cx.Designing then
  311.                Result:='(exename)';
  312.   ftWindows: Result:='Windows';
  313.   ftSystem:  Result:='System';
  314.   ftControl: Result:='Control';
  315.     end;
  316.   if not cx.Designing then
  317.     if (fNameType=ftExeName) or (fFileName^='') then
  318.       Result:=ExtractFileName(paramstr(0));
  319.   if Result='' then
  320.     Result:='Temp';
  321.   if Result<>fFileName^ then
  322.     AssignStr(fFileName,Result);
  323.   Result:=ChangeFileExt(Result,'.INI');
  324. end;
  325.  
  326. function TIniFileLinkFile.GetFilePath: String;
  327. begin
  328.   Result:='';
  329.   if (fLocationType in [flWindowsDir, flSystemDir]) then
  330.     cx.MakeIfNil(fWindowsUserInfo,TWindowsUserInfo);
  331.   case fLocationType of
  332.   flNamed: Result:=fFilePath^; {as is, might be blank}
  333.   flExePath:
  334.     if cx.Designing then
  335.       Result:='(exepath)'; {will set below at runtime}
  336.   flWindowsDir: Result:=fWindowsUserInfo.WindowsPath;
  337.   flSystemDir: Result:=fWindowsUserInfo.SystemPath;
  338.     end;
  339.   if not cx.Designing then
  340.     if (fLocationType=flExePath) or (fFilePath^='') then
  341.       Result:=ExtractFilePath(paramstr(0)); {default}
  342.   if Result='' then
  343.     Result:='C:\';
  344.   if not cx.Designing then
  345.     Result:=TrailingBackSlash(Result);
  346.   if Result<>fFilePath^ then
  347.     AssignStr(fFilePath,Result);
  348. end;
  349.  
  350. {-------------------------------------------------------------------------}
  351.  
  352. function TIniFileLinkFile.GetIniFileName: String;
  353. begin
  354.   Result:=IniPath+IniName; {read properties vis get functions}
  355. end;
  356.  
  357. procedure TIniFileLinkFile.SetIniFileName(const Value: String);
  358. begin
  359.   fLocationType:=flNamed;  {reset the flags so everything's consistent}
  360.   fNameType:=ftNamed;
  361.   AssignStr(fFilePath,TrailingBackSlash(ExtractFilePath(Value)));
  362.   AssignStr(fFileName,ExtractFileName(Value));
  363. end;
  364.  
  365. {-------------------------------------------------------------------------}
  366.  
  367. function TIniFileLinkFile.GetSection:String;
  368. begin
  369.   if fSection^='' then
  370.     Result:='(blank)'
  371.   else
  372.     Result:=fSection^;
  373. end;
  374.  
  375. procedure TIniFileLinkFile.SetSection(const Value:String);
  376. begin
  377.   AssignStr(fSection,Value);
  378. end;
  379.  
  380. function TIniFileLinkFile.GetEntry:String;
  381. begin
  382.   if fEntry^='' then
  383.     Result:='(blank)'
  384.   else
  385.     Result:=fEntry^;
  386. end;
  387.  
  388. procedure TIniFileLinkFile.SetEntry(const Value:String);
  389. begin
  390.   AssignStr(fEntry,Value);
  391. end;
  392.  
  393. {-------------------------------------------------------------------------}
  394.  
  395. function TIniFileLinkFile.FileSectionEntry:String;
  396. begin
  397.   Result:=IniFileName+'['+Section+']'+Entry;
  398. end;
  399.  
  400. {-------------------------------------------------------------------------}
  401.  
  402. function TIniFileLinkFile.IsOpen:Boolean;
  403. begin
  404.   Result:=Handle<>nil;
  405. end;
  406.  
  407. procedure TIniFileLinkFile.Open;
  408. begin
  409.   if cx.Designing then begin
  410.     if fNameType=ftExeName then
  411.       Raise Exception.Create('No ExeName available while designing!'+#13
  412.                             +'Specify another INI-name type for now.');
  413.     if (fLocationType in [flWindowsDir, flSystemDir]) then
  414.       cx.MakeIfNil(fWindowsUserInfo,TWindowsUserInfo);
  415.     end;
  416.   if not IsOpen then
  417.     Handle:=TIniFile.Create(GetIniFileName);
  418. end;
  419.  
  420. procedure TIniFileLinkFile.Close;
  421. begin
  422.   if Handle<>nil then
  423.     Handle.Free;
  424.   Handle:=nil;
  425. end;
  426.  
  427. {-------------------------------------------------------------------------}
  428. { TIniFileLinkData                                                        }
  429. {-------------------------------------------------------------------------}
  430.  
  431. constructor TIniFileLinkData.Create(AOwner: TComponent);
  432. begin
  433.   inherited Create(AOwner);
  434.   fRetry:=TRetry.Create;
  435.   fString:=NullStr;;
  436. end;
  437.  
  438. destructor TIniFileLinkData.Destroy;
  439. begin
  440.   DisposeStr(fString);
  441.   fRetry.Free;
  442.   inherited Destroy;
  443. end;
  444.  
  445. {-------------------------------------------------------------------------}
  446.  
  447. procedure TIniFileLinkData.DoAction(Sender:TObject);
  448. {this proc is called via the retry mechanism}
  449. {compond types based on StringValue will trigger a one level recursion on 'Get'.
  450.  this allows us to do the entire conversion inside the retry shell.}
  451. var
  452.   a1,a2:string;
  453. begin
  454.   Open; {no need to worry about recursing. open/close work via pointer=nil}
  455.  
  456.   with Handle do     {actions listed but not used will probably never trigger errors}
  457.     case fAction of                                               {see procs below}
  458.   iaEraseSection: EraseSection(Section);
  459.     iaEraseEntry:  WriteString(Section,Entry,'');
  460.        iaSetBool:    WriteBool(Section,Entry,fBool);
  461.         iaSetInt: WriteInteger(Section,Entry,fInteger);
  462.      iaSetString:  WriteString(Section,Entry,fString^);
  463.        iaGetBool:       fBool:=ReadBool(Section,Entry,false);
  464.         iaGetInt: fInteger:=ReadInteger(Section,Entry,0);
  465.      iaGetString:   AssignStr(fString,ReadString(Section,Entry,''));
  466.        iaGetChar: ;
  467.        iaSetChar: ;
  468.         iaGetExt: begin
  469.                   a1:=StringValue; {one recursion}
  470.                   fAction:=iaGetExt; {returns here in error}
  471.                   fExt:=StrToFloat(a1);
  472.                   end;
  473.         iaSetExt: ;
  474.       iaGetPoint: with fRect.Topleft do begin
  475.                   SplitString(StringValue,',',a1,a2);
  476.                   fAction:=iaGetPoint;
  477.                   x:=StrToInt(a1);
  478.                   y:=StrToInt(a2);
  479.                   end;
  480.       iaSetPoint: ;
  481.        iaGetRect: with fRect do begin
  482.                   SplitString(StringValue,',',a1,a2);
  483.                   fAction:=iaGetRect;
  484.                   Left:=StrToIntDef(a1,0);
  485.                   SplitString(a2,',',a1,a2);
  486.                   Top:=StrToIntDef(a1,0);
  487.                   SplitString(a2,',',a1,a2);
  488.                   Right:=StrToIntDef(a1,0);
  489.                   Bottom:=StrToIntDef(a2,0);
  490.                   end;
  491.        iaSetRect: ;
  492.        iaGetWPos: with TWindowPosValue(fRect) do begin
  493.                   SplitString(StringValue,',',a1,a2);
  494.                   fAction:=iaGetWPos;
  495.                   Top:=StrToIntDef(a1,0);
  496.                   SplitString(a2,',',a1,a2);
  497.                   Left:=StrToIntDef(a1,0);
  498.                   SplitString(a2,',',a1,a2);
  499.                   Height:=StrToIntDef(a1,0);
  500.                   Width:=StrToIntDef(a2,0);
  501.                   end;
  502.        iaSetWPos: ;
  503.     end;
  504.  
  505.   if not LeaveOpen then
  506.     Close;
  507. end;
  508.  
  509. procedure TIniFileLinkData.DoIniAction(Action:TIniActions);
  510. begin
  511.   fAction:=Action;
  512.   fRetry.RetryAction(DoAction);
  513. end;
  514.  
  515. {-------------------------------------------------------------------------}
  516.  
  517. function TIniFileLinkData.GetOnException:TRetryExceptionEvent;
  518. begin
  519.   Result:=fRetry.OnException;
  520. end;
  521.  
  522. procedure TIniFileLinkData.SetOnException(Value:TRetryExceptionEvent);
  523. begin
  524.   fRetry.OnException:=Value;
  525. end;
  526.  
  527. {-------------------------------------------------------------------------}
  528.  
  529. procedure TIniFileLinkData.EraseSection;
  530. begin
  531.   DoIniAction(iaEraseSection);
  532. end;
  533.  
  534. procedure TIniFileLinkData.EraseEntry;
  535. begin
  536.   DoIniAction(iaEraseEntry);
  537. end;
  538.  
  539. {-------------------------------------------------------------------------}
  540.  
  541. function TIniFileLinkData.GetBooleanValue:Boolean;
  542. begin
  543.   DoIniAction(iaGetBool);
  544.   Result:=fBool;
  545. end;
  546.  
  547. procedure TIniFileLinkData.SetBooleanValue(Value:Boolean);
  548. begin
  549.   fBool:=Value;
  550.   DoIniAction(iaSetBool);
  551. end;
  552.  
  553. {-------------------------------------------------------------------------}
  554.  
  555. function TIniFileLinkData.GetStringValue:String;
  556. begin
  557.   DoIniAction(iaGetString);
  558.   Result:=fString^;
  559. end;
  560.  
  561. procedure TIniFileLinkData.SetStringValue(const Value:String);
  562. begin
  563.   AssignStr(fString,Value);
  564.   DoIniAction(iaSetString);
  565. end;
  566.  
  567. {-------------------------------------------------------------------------}
  568.  
  569. function TIniFileLinkData.GetLongIntValue:LongInt;
  570. begin
  571.   DoIniAction(iaGetInt);
  572.   Result:=fInteger;
  573. end;
  574.  
  575. procedure TIniFileLinkData.SetLongIntValue(Value:LongInt);
  576. begin
  577.   fInteger:=Value;
  578.   DoIniAction(iaSetInt);
  579. end;
  580.  
  581. {-------------------------------------------------------------------------}
  582.  
  583. function TIniFileLinkData.GetCharacterValue:Char;
  584. begin
  585.   DoIniAction(iaGetString);
  586.   Result:=fString^[1];
  587. end;
  588.  
  589. procedure TIniFileLinkData.SetCharacterValue(Value:Char);
  590. begin
  591.   AssignStr(fString,Value);
  592.   DoIniAction(iaSetString);
  593. end;
  594.  
  595. {-------------------------------------------------------------------------}
  596.  
  597. function TIniFileLinkData.GetExtendedValue:Extended;
  598. begin
  599.   fExt:=0;
  600.   DoIniAction(iaGetExt);
  601.   Result:=fExt;
  602. end;
  603.  
  604. procedure TIniFileLinkData.SetExtendedValue(Value:Extended);
  605. begin
  606.   StringValue:=FloatToStr(Value);
  607. end;
  608.  
  609. {-------------------------------------------------------------------------}
  610.  
  611. function TIniFileLinkData.GetPointValue:TPoint;
  612. begin
  613.   DoIniAction(iaGetPoint);
  614.   Result:=fRect.TopLeft;
  615. end;
  616.  
  617. procedure TIniFileLinkData.SetPointValue(Value:TPoint);
  618. begin
  619.   with Value do
  620.     StringValue:=inttostr(x)+','+inttostr(y);
  621. end;
  622.  
  623. {-------------------------------------------------------------------------}
  624.  
  625. function TIniFileLinkData.GetRectValue:TRect;
  626. begin
  627.   DoIniAction(iaGetRect);
  628.   Result:=fRect;
  629. end;
  630.  
  631. procedure TIniFileLinkData.SetRectValue(Value:TRect);
  632. begin
  633.   with Value do
  634.     StringValue:=inttostr(Left)+','+inttostr(Top)+','
  635.                 +inttostr(Right)+','+inttostr(Bottom);
  636. end;
  637.  
  638. {-------------------------------------------------------------------------}
  639.  
  640. function TIniFileLinkData.GetWindowPosValue:TWindowPosValue;
  641. begin
  642.   DoIniAction(iaGetWPos);
  643.   Result:=TWindowPosValue(fRect);
  644. end;
  645.  
  646. procedure TIniFileLinkData.SetWindowPosValue(Value:TWindowPosValue);
  647. begin
  648.   with Value do
  649.     StringValue:=inttostr(Top)+','+inttostr(Left)+','
  650.                 +inttostr(Height)+','+inttostr(Width);
  651. end;
  652.  
  653. {-------------------------------------------------------------------------}
  654.  
  655. procedure TIniFileLinkData.StoreControlPos(Control:TControl);
  656. var
  657.   wp:TWindowPosValue;
  658. begin
  659.   with Control do begin
  660.     wp.Top:=Top;
  661.     wp.Left:=Left;
  662.     wp.Width:=Width;
  663.     wp.Height:=Height;
  664.     end;
  665.   WindowPosValue:=wp;
  666. end;
  667.  
  668. procedure TIniFileLinkData.LoadControlPos(Control:TControl);
  669. var
  670.   wp:TWindowPosValue;
  671. begin
  672.   wp:=WindowPosValue;
  673.   with wp do begin
  674.     Control.Top:=Top;
  675.     Control.Left:=Left;
  676.     Control.Width:=Width;
  677.     Control.Height:=Height;
  678.     end;
  679. end;
  680.  
  681. {-------------------------------------------------------------------------}
  682. { TIniFileLink                                                            }
  683. {-------------------------------------------------------------------------}
  684.  
  685. constructor TIniFileLink.Create(AOwner: TComponent);
  686. begin {required to activate virtual methods. would compile without but works wrong then!}
  687.   inherited Create(AOwner);
  688. end;
  689.  
  690. procedure TIniFileLink.Notification(AComponent: TComponent; Operation: TOperation);
  691. begin
  692.   inherited Notification(AComponent, Operation);
  693. end;
  694.  
  695. {-------------------------------------------------------------------------}
  696.  
  697. function TIniFileLink.GetBooleanEntry(const aEntry:String):Boolean;
  698. begin
  699.   Entry:=aEntry;
  700.   Result:=BooleanValue;
  701. end;
  702.  
  703. procedure TIniFileLink.SetBooleanEntry(const aEntry:String;Value:Boolean);
  704. begin
  705.   Entry:=aEntry;
  706.   BooleanValue:=Value;
  707. end;
  708.  
  709. {-------------------------------------------------------------------------}
  710. function TIniFileLink.GetLongIntEntry(const aEntry:String):LongInt;
  711. begin
  712.   Entry:=aEntry;
  713.   Result:=LongIntValue;
  714. end;
  715.  
  716. procedure TIniFileLink.SetLongIntEntry(const aEntry:String;Value:LongInt);
  717. begin
  718.   Entry:=aEntry;
  719.   LongIntValue:=Value;
  720. end;
  721.  
  722. {-------------------------------------------------------------------------}
  723. function TIniFileLink.GetStringEntry(const aEntry:String):String;
  724. begin
  725.   Entry:=aEntry;
  726.   Result:=StringValue;
  727. end;
  728.  
  729. procedure TIniFileLink.SetStringEntry(const aEntry:String;const Value:String);
  730. begin
  731.   Entry:=aEntry;
  732.   StringValue:=Value;
  733. end;
  734.  
  735. {-------------------------------------------------------------------------}
  736. function TIniFileLink.GetCharacterEntry(const aEntry:String):Char;
  737. begin
  738.   Entry:=aEntry;
  739.   Result:=CharacterValue;
  740. end;
  741.  
  742. procedure TIniFileLink.SetCharacterEntry(const aEntry:String;Value:Char);
  743. begin
  744.   Entry:=aEntry;
  745.   CharacterValue:=Value;
  746. end;
  747.  
  748. {-------------------------------------------------------------------------}
  749. function TIniFileLink.GetExtendedEntry(const aEntry:String):Extended;
  750. begin
  751.   Entry:=aEntry;
  752.   Result:=ExtendedValue;
  753. end;
  754.  
  755. procedure TIniFileLink.SetExtendedEntry(const aEntry:String;Value:Extended);
  756. begin
  757.   Entry:=aEntry;
  758.   ExtendedValue:=Value;
  759. end;
  760.  
  761. {-------------------------------------------------------------------------}
  762. function TIniFileLink.GetPointEntry(const aEntry:String):TPoint;
  763. begin
  764.   Entry:=aEntry;
  765.   Result:=PointValue;
  766. end;
  767.  
  768. procedure TIniFileLink.SetPointEntry(const aEntry:String;Value:TPoint);
  769. begin
  770.   Entry:=aEntry;
  771.   PointValue:=Value;
  772. end;
  773.  
  774. {-------------------------------------------------------------------------}
  775. function TIniFileLink.GetRectEntry(const aEntry:String):TRect;
  776. begin
  777.   Entry:=aEntry;
  778.   Result:=RectValue;
  779. end;
  780.  
  781. procedure TIniFileLink.SetRectEntry(const aEntry:String;Value:TRect);
  782. begin
  783.   Entry:=aEntry;
  784.   RectValue:=Value;
  785. end;
  786.  
  787. {-------------------------------------------------------------------------}
  788.  
  789. function TIniFileLink.GetWindowPosEntry(const aEntry:String):TWindowPosValue;
  790. begin
  791.   Entry:=aEntry;
  792.   Result:=WindowPosValue;
  793. end;
  794.  
  795. procedure TIniFileLink.SetWindowPosEntry(const aEntry:String;Value:TWindowPosValue);
  796. begin
  797.   Entry:=aEntry;
  798.   WindowPosValue:=Value;
  799. end;
  800.  
  801. {-------------------------------------------------------------------------}
  802.  
  803. end.
  804.